package s05.polimorfismo;

public final class ComissionWorker extends Employee {
	private double salary;
	private double commission;
	private int quantity; //total de itens vendidos na semana.
	
	public ComissionWorker(String first, String last, double salary, double commission, int quantity) {
		super(first, last);
		setSalary(salary);
		setCommission(commission);
	}

	public void setSalary (double weeklySalary) {
		salary = (weeklySalary > 0 ? weeklySalary : 0);
	}
	
	public void setCommission (double itemCommission) {
		commission = (itemCommission > 0 ? itemCommission : 0);
	}
	public void setQuantity (int totalSold) {
		quantity = (totalSold > 0 ? totalSold : 0);
	}
	
	@Override
	public double earnings() {
		return salary + commission * quantity;
	}
	
	public String toString() {
		return "Commission worker: " + super.toString();
	}

}
